home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
cuj1008.zip
/
1008133A
< prev
next >
Wrap
Text File
|
1992-06-09
|
1KB
|
36 lines
#define MAX_STRINGS 100
#define SIZE_STRING 100
#define SIZE_ALL_STRINGS 5000
char *get_string(int index)
{
static char *string[MAX_STRINGS];
static char *string_buffer;
static int initialized;
int size;
int total_size = 0;
int count;
FILE *string_file;
if (!initialized)
{
string_buffer = calloc(SIZE_ALL_STRINGS, 1);
string_file = fopen("string.fil","r");
/* Read the file into string_buffer */
string[0] = string_buffer;
size = 0;
for (count = 0; count < MAX_STRINGS; count++)
{
fgets(string_file, string[count], SIZE_STRING);
size = strlen(string[count]);
string[count][size - 1] = '\0';
size--;
total_size += size;
string[count+1] = string_buffer + total_size;
}
initialized = 1;
}
return string[index];
}